<?php
/*
 * 管理员类
 */
class User_Manager extends User_Base
{
	const _role_id	= '';

	public function __construct ($uid = NULL, $user_info = NULL)
	{
		parent::__construct($uid);
        $this->_user_info['role_id'] = $this->get_role_id();
	}

	public static function factory($uid,$info)
	{
		$type	= $info['utype'];	
		$role_id		= self::reset_user_role($uid);
		
		switch($role_id)
		{
			case 'commonmanager' :
				return new User_Manager_Common($uid, $info);
			
			case 'auditor' :
				return new User_Manager_Auditor($uid, $info);
			
			case 'financial' :
				return new User_Manager_Financial($uid, $info);

			case 'operator' :
				return new User_Manager_Operator($uid, $info);
			
			case 'supermanager' :
				return new User_Manager_SuperManager($uid, $info);

			case 'yyhyunying' :
				return new User_Manager_YYHYunYing($uid, $info);

			default :
				return new User_Manager_Common($uid, $info);
		}
	}

    /**
     * 设置管理员的具体角色
     *
     * @param   string  $role_key_name
     * @return  boolean
     */
    public function set_user_role ($role_key_name)
    {
        $role = new User_Role_Role;
        $role->set_user_role_by_name ($this->_user_id, $role_key_name);
    }

	//获得用户角色ID 
	private static function reset_user_role($uid)
	{
		$rs	= User_Role_Role::get_user_role($uid);

		return empty($rs) ? self::_role_id : $rs;
	}
}
